package com.hljx.controller;

import com.hljx.config.Result;
import com.hljx.mapper.his.HisAdviceItemMapper;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.batch.core.*;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
import org.springframework.batch.core.repository.JobRestartException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 医嘱项目表 前端控制器
 * </p>
 *
 * @author lp
 * @since 2023-09-25
 */
@RestController
@RequestMapping("/adviceItem")
public class AdviceItemController {
@Autowired
private HisAdviceItemMapper hisAdviceItemMapper;
@Autowired
private JobLauncher jobLauncher;
@Autowired
@Qualifier("rEmployeeJob")
private Job sampleJob;

    @Operation(description = "SSSS")
    @GetMapping("/run_job1")
    public Result runJob1() throws JobParametersInvalidException, JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException {

        JobParameters jobParameters = new JobParametersBuilder()
                .addLong("time",System.currentTimeMillis())
                .toJobParameters();
        JobExecution run = jobLauncher.run(sampleJob, jobParameters);
        return Result.success();
    }

    @Operation(description = "test")
    @GetMapping("/test")
    public Result test(){


        return Result.success(hisAdviceItemMapper.listAll());
    }


}
